package org.artifact.extra;

import akka.AkkaAsk;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : SandKing
 * @CreateDate : 2019/4/29 16:22
 * @Description ：Please describe this document
 */
public class AkkaDemo {
    public static void main(String[] args) {
        ActorSystem osActor = ActorSystem.create("asb");

        ActorRef actor1 = osActor.actorOf(Props.create(MyActor.class), "a");
        ActorRef actor2 = osActor.actorOf(Props.create(MyActor.class), "b");

        Map<String, Integer> map = new HashMap();
        map.put("1", 1);

        actor1.tell(new AkkaAsk<Map, Integer>(map, k -> {
            return MapUtil.getInt(k, "1") + 50;
        }, v -> {
            Console.log(v);
        }), actor2);
    }
}
